package alipay.openplatform.edu.campus.jiuye.common.enums;

/**
 * @author yuxi
 *         返回结果集
 *         Created by yuxi on 16/8/26.
 */
public enum ResultCode {

    STATUS_OK("0", "操作成功"),
    NO_DATA("1","没有请求数据"),
    NO_Param("2","没有收到前台参数"),
    ID_ERRO("20","身份证号输入有误"),
    FRONT_PARAM_ERRO("21","前端传入信息和实际信息不符"),
    FRONT_MONEY_ERRO("22","前端传入还款金额与实际应还款金额不符"),
    NOT_PAYMONEY("23","无未还款账单"),
    NOT_FULLMONEY("24","无法全额还款"),
    NOT_PERIOD("25","期数与还款金额不符"),
    CAPTCHA_ERR
            ("201", "验证码错误"),
    USERNAME_OR_PWD_ERR
            ("301", "用户名或密码错误"),
    AUTH_UNAUTHORIZED("401", "用户未登录"),
    REPEAT_HANDLE_EXCEPTION(
            "402",
            "频繁操作"),
    AUTH_USER_ALREADY(
            "403", " 用户已经登录,需要跳转到首页"),
    SYSTEM_EXCEIPTION(
            "500", "系统异常"),
    SERVICE_EXCEIPTION(
            "501", "系统服务异常"),
    AUTH_LOGOUT_FAIL(
            "1001", "退出登录失败"),
    AUTH_LOGIN_INVALID_PARAMS
            ("1002", "登录参数有误"),
    AUTH_LOGIN_FAILED
            ("1003", "账号或密码错误,请重试"),
    AUTH_LOGIN_ERROR
            ("1004", "用户已被锁定,请稍后再试"),
    AUTH_MAX_TIME_REACH
            ("1006", "登录超过最大尝试次数"),
    AUTH_SMS_CODE_FAIL
            ("1007", "短信验证码不匹配"),
    AUTH_USER_EXITS
            ("1008", "用户已存在"),
    AUTH_USER_NOT_EXITS
            ("1009", "用户不存在"),
    AUTH_SET_PAYPASS_FAIL
            ("1010", "设置支付密码失败"),
    AUTH_INVALID_PHONE
            ("1011", "手机号格式不正确"),
    AUTH_CHECK_PAYPASS_FAIL
            ("1012", "校验支付密码失败"),
    AUTH_ALIPAY_ACCOUNT_FAIL
            ("1013", "设置支付宝收款账号失败"),
    SMS_WRONG_PARAMS
            ("2001", "发送短信参数有误"),
    SMS_SEND_MAX_TIMES
            ("2002", "短信发送超过限额"),
    NEED_CAPTCHA
            ("2003", "需要图片验证码"),
    AREA_NOT_EXITS
            ("2004", "区域不存在"),
    INVALID_ADDRESS
            ("2005", "地址不合法,同时校验省市区及关联性"),
    ADD_ADDRESS_FAILD
            ("2006", "添加用户地址失败"),
    REACH_PAYPASS_LIMIT
            ("2007", "支付密码尝试次数达到上限"),
    SIMILAR_ADDRESS
            ("2009", "相似的用户地址"),
    SMS_SEND_OFFEN
            ("2010", "请勿频繁发送短信验证码"),
    SMS_SEND_DAILY_LIMIT
            ("2011", "短信发送超过当日限额,请明日再试"),
    FORM_VALIDATE_FAILD
            ("3001", "表单校验失败"),
    ALIPAY_AGREEMENT_NEED_SIGN
            ("4000", "用户尚未签署代扣协议"),
    ALIPAY_AGREEMENT_SIGN_FAIL
            ("4001", "支付宝代扣授权失败"),
    ZM_NOT_AUTHORIZED
            ("4002", "芝麻未授权"),
    ZM_NOTIFY_ERROR
            ("4003", "芝麻授权失败"),
    ZM_CHECK_PHONE_FAIL
            ("4004", "芝麻校验手机号关联性失败"),
    ALIPAY_PAY_FAIL
            ("4005", "调用支付宝收款失败"),
    ALIPAY_ACCOUNT_NOT_SET
            ("4006", "支付宝收款账号未设置"),
    USER_ADDRESS_UPDATE_FAILD
            ("5001", "更新用户地址失败"),
    USER_CREDIT_NOT_ENOUGH
            ("5002", "用户额度不足"),
    USER_STATUS_DENY
            ("5003", "用户状态校验失败"),
    USER_BILL_OVERDUE
            ("5004", "用户有逾期未还订单,无法下单"),
    CREDIT_APPLY_FAILD
            ("6000", "提现申请提交失败"),
    MAX_DAILY_GRANT_REACH
            ("6001", "达到每日评估次数上限"),
    GRANT_CREDIT_FAIL
            ("6002", "授信额度失败"),
    RISK_STATE_FAILD
            ("6003", "风控未通过"),
    ORDER_ON_THR_AIR
            ("7001", "尚有订单在打款中"),
    ADD_TOPICINFO_FAIL
            ("8001","创建专题信息失败"),
    UPDATE_TOPICINFO_FAIL
            ("8002","修改专题信息失败"),
    ADD_LOGO_FAIL("8003","添加logo信息失败"),
    DEL_LOGO_FAIL("8004","删除logo信息失败"),
    GET_LOGO_INFO("8005","获取运营位信息-后台"),
    GET_CURRENT_LOGO_INFO("8006","获取当前的运营位列表"),
    GET_AD_INFO("8007","获取广告位列表失败"),
    GET_USER_TOPIC("8008","分页获取用户收藏的主题的列表"),
    HANDLE_FAIL
            ("-1","操作失败");
    private String code;
    private String name;

    ResultCode(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据名称得到码
     *
     * @param name
     * @return
     */
    public static String getCode(String name) {
        for (ResultCode enumType : ResultCode.values()) {
            if (name != null && name.equals(enumType.getName())) {
                return enumType.getCode();
            }
        }
        return null;
    }

    /**
     * 根据码得到名称
     *
     * @param code
     * @return
     */
    public static String getName(String code) {
        for (ResultCode enumType : ResultCode.values()) {
            if (code.equals(enumType.getCode())) {
                return enumType.getName();
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
